home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / demosrc / cfsource / part1.pas < prev    next >
Pascal/Delphi Source File  |  1993-10-30  |  31KB  |  1,211 lines

  1. {$R-,S-}
  2. PROGRAM PaletteStars;
  3. USES
  4.     Crt,MCGA,Tools;
  5. TYPE
  6.     ByteArray=ARRAY[0..65534] OF Byte;
  7. VAR
  8.    StartLogoSpr:Pointer;
  9.    FontCh:ARRAY[1..2,0..255] OF ^ByteArray;
  10.    Color,Gray:Byte;
  11.    I,J,K,Phase,Radius,StartR,StartG,StartB,OfsLines,Count,RasterLine,C,IncC,
  12.    Dir,LastOfs:Integer;
  13.    SpiralTab:ARRAY[0..127] OF Integer;
  14.    BarTab:ARRAY[0..799] OF Byte;
  15.    BarStartTab:ARRAY[0..255] OF Integer;
  16.    SinVertTab:ARRAY[0..1023] OF Integer;
  17.    Adr,Start:Word;
  18.    Cancel:Boolean;
  19.    BarLine:ARRAY[0..319] OF Byte;
  20.    Factor:ARRAY[0..63] OF Integer;
  21.    StartGap:ARRAY[0..63,0..5] OF Integer;
  22.    AardTextSpr:Pointer;
  23.    ScrollText1:String;
  24.    StandardPal:ARRAY[0..255,1..3] OF Byte;
  25.    F:File;
  26.    Line:ARRAY[0..1023] OF Word;
  27.    Line2:ARRAY[0..1023] OF Integer;
  28.    Pal:ARRAY[0..127] OF Byte;
  29.    OfsRel,OfsTable:ARRAY[0..1023] OF Integer;
  30.    SinTable:ARRAY[0..255] OF Byte;
  31.  
  32. PROCEDURE LoadFontMCF(Font:Byte; FontName:String);
  33. VAR
  34.    FontFile:File;
  35.    I:Byte;
  36.    L:LongInt;
  37.    X,Y:Integer;
  38.    Size:Word;
  39. BEGIN
  40.      Assign(FontFile,FontName+'.MCF');
  41.      Reset(FontFile,1);
  42.      FOR I:=0 TO 255 DO
  43.      BEGIN
  44.           FontCh[Font,I]:=NIL;
  45.           BlockRead(FontFile,L,4);
  46.           X:=Integer(L);
  47.           Y:=L SHR 16;
  48.           Size:=(X+1)*(Y+1);
  49.           IF X*Y>0 THEN
  50.           BEGIN
  51.                GetMem(FontCh[Font,I],Size+4);
  52.                FontCh[Font,I]^[0]:=Lo(X);
  53.                FontCh[Font,I]^[1]:=Hi(X);
  54.                FontCh[Font,I]^[2]:=Lo(Y);
  55.                FontCh[Font,I]^[3]:=Hi(Y);
  56.                BlockRead(FontFile,FontCh[Font,I]^[4],Size);
  57.           END;
  58.      END;
  59. END;
  60.  
  61. PROCEDURE PutImageOn(X1,Y1:Integer; P:Pointer);
  62. VAR
  63.    Adr,I,XS,YS:Word;
  64. BEGIN
  65.      Adr:=Word(Y1)*80+X1 SHR 2;
  66.      FOR I:=0 TO 3 DO
  67.      BEGIN
  68.           SetReadMap(I);
  69.           SetWriteMap(1 SHL I);
  70.           ASM
  71.              push ds
  72.              lds si,p
  73.              lodsw
  74.              mov xs,ax
  75.              mov bx,ax
  76.              inc bx
  77.              lodsw
  78.              add si,i
  79.              mov ys,ax
  80.              mov dx,ax
  81.              inc dx
  82.              mov ax,0a000h
  83.              mov es,ax
  84.              mov di,adr
  85.              mov ah,64
  86.              cld
  87.              shr bx,2
  88.      @1:     mov cx,bx
  89.      @2:     lodsb
  90.              add si,3
  91.              cmp al,0
  92.              jz @3
  93.              or es:[di],ah
  94.      @3:     inc di
  95.              loop @2
  96.              add di,80
  97.              sub di,bx
  98.              dec dx
  99.              jnz @1
  100.              pop ds
  101.           END;
  102.      END;
  103. END;
  104.  
  105. PROCEDURE PutImageOff(X1,Y1:Integer; P:Pointer);
  106. VAR
  107.    Adr,I,XS,YS:Word;
  108. BEGIN
  109.      Adr:=Word(Y1)*80+X1 SHR 2;
  110.      FOR I:=0 TO 3 DO
  111.      BEGIN
  112.           SetReadMap(I);
  113.           SetWriteMap(1 SHL I);
  114.           ASM
  115.              push ds
  116.              lds si,p
  117.              lodsw
  118.              mov xs,ax
  119.              mov bx,ax
  120.              inc bx
  121.              lodsw
  122.              add si,i
  123.              mov ys,ax
  124.              mov dx,ax
  125.              inc dx
  126.              mov ax,0a000h
  127.              mov es,ax
  128.              mov di,adr
  129.              mov ah,191
  130.              cld
  131.              shr bx,2
  132.      @1:     mov cx,bx
  133.      @2:     lodsb
  134.              add si,3
  135.              cmp al,0
  136.              jz @3
  137.              and es:[di],ah
  138.      @3:     inc di
  139.              loop @2
  140.              add di,80
  141.              sub di,bx
  142.              dec dx
  143.              jnz @1
  144.              pop ds
  145.           END;
  146.      END;
  147. END;
  148.  
  149. PROCEDURE PutChar(Font:Byte; X,Y:Integer; Ch:Char; OnOff:Boolean);
  150. BEGIN
  151.      IF FontCh[Font,Ord(Ch)]<>NIL THEN
  152.         IF OnOff THEN
  153.            PutImageOn(X,Y,FontCh[Font,Ord(Ch)])
  154.         ELSE PutImageOff(X,Y,FontCh[Font,Ord(Ch)]);
  155. END;
  156.  
  157. PROCEDURE PutString(Font:Byte; X,Y:Integer; S:String; Distance:Integer; OnOff:Boolean);
  158. VAR
  159.    I:Integer;
  160. BEGIN
  161.      FOR I:=1 TO Length(S) DO
  162.      BEGIN
  163.           PutChar(Font,X,Y,S[I],OnOff);
  164.           Inc(X,Distance);
  165.      END;
  166. END;
  167.  
  168. PROCEDURE SetPixel4(X,Y:Integer; C:Byte);
  169. BEGIN
  170.      SetWriteMap(1 SHL (X AND 3));
  171.      Mem[$A000:Y*80+X SHR 2]:=C;
  172. END;
  173.  
  174. FUNCTION GetPixel4(X,Y:Integer):Byte;
  175. BEGIN
  176.      SetReadMap(X AND 3);
  177.      GetPixel4:=Mem[$A000:Y*80+X SHR 2];
  178. END;
  179.  
  180. PROCEDURE MakeStar;
  181. VAR
  182.    I,X,Y,XP,YP:Integer;
  183.    Shift,Value:Byte;
  184.    InRange:Boolean;
  185. BEGIN
  186.      REPEAT
  187.            X:=Integer(Random(500)-250);
  188.            Y:=Integer(Random(800)-400);
  189.      UNTIL (X<-160) OR (X>160) OR (Y<-100) OR (Y>100);
  190.      Shift:=Random(64);
  191.      X:=X SHL 4;
  192.      Y:=Y SHL 4;
  193.      FOR I:=63 DOWNTO 8 DO
  194.      BEGIN
  195.           XP:=Factor[I];
  196.           ASM
  197.              mov cl,0
  198.              mov ax,xp
  199.              mov bx,ax
  200.              imul x
  201.              add dx,160
  202.              or dx,dx
  203.              jl @1
  204.              cmp dx,319
  205.              jg @1
  206.              mov xp,dx
  207.              mov ax,bx
  208.              imul y
  209.              add dx,200
  210.              or dx,dx
  211.              jl @1
  212.              cmp dx,399
  213.              jg @1
  214.              mov yp,dx
  215.              mov cl,1
  216. @1:          mov inrange,cl
  217.           END;
  218.           IF InRange THEN
  219.           BEGIN
  220.                Value:=GetPixel4(XP,YP);
  221.                IF Value<127 THEN
  222.                   SetPixel4(XP,YP,Value AND 64+((I+Shift) AND 63));
  223.           END;
  224.      END;
  225. END;
  226.  
  227. PROCEDURE CalcFactors;
  228. VAR
  229.    I:Integer;
  230. BEGIN
  231.      FOR I:=8 TO 63 DO
  232.          Factor[I]:=65535 DIV (I+8);
  233. END;
  234.  
  235. PROCEDURE ActiveTransparent(Nr:Integer);
  236. VAR
  237.    Ph:Integer;
  238. BEGIN
  239.      Ph:=Phase-Nr;
  240.      IF Ph<64 THEN
  241.         SetColor(64+I,127-Ph,63,127-Ph)
  242.      ELSE SetColor(64+I,(Ph-64) SHR 1,63,(Ph-64) SHR 1);
  243. END;
  244.  
  245. PROCEDURE PassiveTransparent(Nr:Integer);
  246. VAR
  247.    Ph,I:Integer;
  248. BEGIN
  249.      Ph:=Phase-Nr;
  250.      IF Ph<64 THEN
  251.         FOR I:=0 TO 63 DO
  252.             SetColor(64+I,Ph,0,0)
  253.      ELSE
  254.      FOR I:=0 TO 63 DO
  255.          SetColor(64+I,(191-Ph) SHR 1,0,0);
  256. END;
  257.  
  258. FUNCTION Range(Nr:Integer):Boolean;
  259. BEGIN
  260.      Range:=(Phase>=Nr) AND (Phase<=Nr+191);
  261. END;
  262.  
  263. PROCEDURE DrawRectangle(Ph:Integer);
  264. BEGIN
  265.      DrawLineH4(1399-Ph,Ph-1080,(1400-Ph) SHL 1-2,129);
  266.      DrawLineH4(1399-Ph,Ph-1080,(1400-Ph) SHL 1-1,129);
  267.      DrawLineH4(1399-Ph,Ph-1080,(Ph-1200) SHL 1,129);
  268.      DrawLineH4(1399-Ph,Ph-1080,(Ph-1200) SHL 1+1,129);
  269.      DrawLineV4(1399-Ph,(1400-Ph) SHL 1,(Ph-1200) SHL 1-1,129);
  270.      DrawLineV4(Ph-1080,(1400-Ph) SHL 1,(Ph-1200) SHL 1-1,129);
  271. END;
  272.  
  273. PROCEDURE DrawFontBar(I,J:Integer);
  274. BEGIN
  275.      IF I<64 THEN
  276.      BEGIN
  277.           Count:=StartGap[I,J]-StartGap[I,J-1];
  278.           SetOffset(40);
  279.           FOR I:=0 TO 12 DO
  280.           BEGIN
  281.                Wait4Line;
  282.                Inc(RasterLine);
  283.           END;
  284.           SetOffset(0);
  285.           FOR I:=0 TO Count-1 DO
  286.           BEGIN
  287.                Wait4Line;
  288.                Inc(RasterLine);
  289.           END;
  290.      END
  291.      ELSE
  292.      BEGIN
  293.           SetOffset(40);
  294.           IF J=1 THEN
  295.           BEGIN
  296.                Wait4Line;
  297.                Inc(RasterLine);
  298.           END;
  299.           FOR I:=0 TO 10 DO
  300.           BEGIN
  301.                Wait4Line;
  302.                Inc(RasterLine);
  303.           END;
  304.           SetOffset(80);
  305.           Wait4Line;
  306.           Inc(RasterLine);
  307.      END;
  308. END;
  309.  
  310. {
  311. PROCEDURE DrawFontBar(I,J:Integer);
  312. BEGIN
  313.      IF I<64 THEN
  314.      BEGIN
  315.           Count:=StartGap[I,J]-StartGap[I,J-1];
  316.           ASM
  317.              mov dx,$3d4
  318.              mov ax,$2813
  319.              out dx,ax
  320.  
  321.              mov cx,13
  322.              mov dx,$3da
  323. @1:          in al,dx
  324.              test al,1
  325.              jnz @1
  326. @2:          in al,dx
  327.              test al,1
  328.              jz @2
  329.              loop @1
  330.  
  331.              mov dx,$3d4
  332.              mov ax,$0013
  333.              out dx,ax
  334.  
  335.              mov cx,count
  336.              jcxz @5
  337.              mov dx,$3da
  338. @3:          in al,dx
  339.              test al,1
  340.              jnz @3
  341. @4:          in al,dx
  342.              test al,1
  343.              jz @4
  344.              loop @3
  345. @5:      END;
  346.      END
  347.      ELSE
  348.      BEGIN
  349.           ASM
  350.              mov dx,$3d4
  351.              mov ax,$2813
  352.              out dx,ax
  353.  
  354.              mov cx,12
  355.              mov al,byte ptr j
  356.              cmp al,1
  357.              jz @0
  358.              dec cx
  359. @0:          mov dx,$3da
  360. @1:          in al,dx
  361.              test al,1
  362.              jnz @1
  363. @2:          in al,dx
  364.              test al,1
  365.              jz @2
  366.              loop @1
  367.  
  368.              mov dx,$3d4
  369.              mov ax,$5013
  370.              out dx,ax
  371.  
  372.              mov dx,$3da
  373. @3:          in al,dx
  374.              test al,1
  375.              jnz @3
  376. @4:          in al,dx
  377.              test al,1
  378.              jz @4
  379.           END;
  380.      END;
  381. END;
  382. }
  383.  
  384. PROCEDURE DrawPlasma;
  385. VAR
  386.    I:Integer;
  387. BEGIN
  388.      ASM
  389.         mov si,offset pal
  390.         xor cx,cx
  391.         mov di,j
  392.         cld
  393. @1:     mov bx,di
  394.         add bx,cx
  395.         and bx,127
  396.         mov [si+bx],cl
  397.         mov bx,di
  398.         add bx,127
  399.         sub bx,cx
  400.         and bx,127
  401.         mov [si+bx],cl
  402.         inc cx
  403.         cmp cx,64
  404.         jnz @1
  405.      END;
  406.      WaitScreen;
  407.      ASM
  408.         xor cx,cx
  409.         mov dx,03c8h
  410.         mov al,128
  411.         out dx,al
  412.         mov si,offset pal
  413.         cld
  414.         mov bx,start
  415.         shl bx,1
  416. @0:     and bx,1023
  417.         mov ah,[bx+offset ofstable]
  418.         mov al,13h
  419.         mov dx,03d4h
  420.         out dx,ax
  421.         inc bx
  422.  
  423.         mov dx,03dah
  424. @1:     in al,dx
  425.         test al,1
  426.         jnz @1
  427.  
  428.         mov dx,03c9h
  429.         lodsb
  430.         out dx,al
  431.         mov al,0
  432.         out dx,al
  433.         out dx,al
  434.  
  435.         mov dx,03dah
  436. @2:     in al,dx
  437.         test al,1
  438.         jz @2
  439.  
  440.         inc cx
  441.         cmp cx,128
  442.         jnz @0
  443.      END;
  444.      ASM
  445.         mov si,start
  446.         shl si,1
  447.         add si,128
  448.         cld
  449. @0:     and si,1023
  450.         mov ah,[si+offset ofstable]
  451.  
  452.         mov dx,03dah
  453. @1:     in al,dx
  454.         test al,1
  455.         jnz @1
  456.  
  457.         mov al,13h
  458.         mov dx,03d4h
  459.         out dx,ax
  460.         inc si
  461.  
  462.         mov dx,03dah
  463. @2:     in al,dx
  464.         test al,1
  465.         jz @2
  466.  
  467.         inc cx
  468.         cmp cx,399
  469.         jnz @0
  470.      END;
  471.      WaitRetrace;
  472. END;
  473.  
  474. BEGIN
  475. { General initialization of tables }
  476.      Init13X;
  477.      SetLineRepeat(0);
  478.      LoadFontMCF(2,'32X64TST');
  479.      FOR I:=0 TO 63 DO
  480.          FOR J:=0 TO 5 DO
  481.              StartGap[I,J]:=Round(16*J*Sin(I/64*Pi));
  482.      Assign(F,'STANDARD.PAL');
  483.      Reset(F,1);
  484.      BlockRead(F,StandardPal,768);
  485.      Close(F);
  486. { Part I - Palette Starfield + Transparent Text }
  487.      LoadSprite('STARTLOG',StartLogoSpr);
  488.      CalcFactors;
  489.      FOR I:=0 TO 255 DO
  490.          SetColor(I,0,0,0);
  491.      SetColor(128,0,0,63);
  492.      SetColor(129,0,0,31);
  493.      PutImage4(70,140,StartLogoSpr^);
  494.      LoadFontMCF(1,'CLEAN16');
  495.      Phase:=0;
  496.      I:=63;
  497.      Gray:=0;
  498.      REPEAT
  499.            IF Phase<63 THEN
  500.               Inc(Gray);
  501. {
  502.            IF Phase>1336 THEN
  503.               Dec(Gray);
  504. }
  505.            IF Phase>=1330 THEN
  506.            BEGIN
  507.                 DrawRectangle(Phase);
  508.                 IF Phase>=1336 THEN
  509.                    SetColor(129,Phase-1336,Phase-1336,Phase-1336)
  510.                 ELSE SetColor(129,0,0,0);
  511.            END;
  512.            IF Phase<1000 THEN
  513.            BEGIN
  514.                 MakeStar;
  515.                 MakeStar;
  516.                 MakeStar;
  517.                 MakeStar;
  518.                 MakeStar;
  519.            END;
  520.            VerticalRetrace;
  521.            SetColor(I,0,0,0);
  522.            IF I=1 THEN
  523.               SetColor(63,Gray,Gray,Gray)
  524.            ELSE SetColor(I-1,Gray,Gray,Gray);
  525.            IF Phase=100 THEN
  526.               PutString(1,72,40,'',16,TRUE)
  527.            ELSE
  528.            IF Phase=300 THEN
  529.            BEGIN
  530.                 PutString(1,72,40,'GREETINGS FOLKS',16,FALSE);
  531.                 PutString(1,32,300,'THIS IS OUR NEW',16,TRUE);
  532.            END
  533.            ELSE
  534.            IF Phase=500 THEN
  535.            BEGIN
  536.                 PutString(1,32,300,'THIS IS OUR NEW',16,FALSE);
  537.                 PutString(1,12,80,'DENTRO CALLED',16,TRUE);
  538.            END
  539.            ELSE
  540.            IF Phase=700 THEN
  541.            BEGIN
  542.                 PutString(1,12,80,'DENTRO CALLED',16,FALSE);
  543.                 PutString(1,72,280,'COPPER FAKED',16,TRUE);
  544.            END
  545.            ELSE
  546.            IF Phase=900 THEN
  547.            BEGIN
  548.                 PutString(1,72,280,'COPPER FAKED',16,FALSE);
  549.                 PutString(1,20,40,'STARRING THE FAKER',16,TRUE);
  550.            END
  551.            ELSE
  552.            IF Phase=1100 THEN
  553.            BEGIN
  554.                 PutString(1,20,40,'STARRING THE FAKER',16,FALSE);
  555.                 PutString(1,0,320,'AND 4999 OTHER STARS',16,TRUE);
  556.            END;
  557.            IF Range(100) THEN
  558.               PassiveTransparent(100)
  559.            ELSE
  560.            IF Range(300) THEN
  561.               PassiveTransparent(300)
  562.            ELSE
  563.            IF Range(500) THEN
  564.               PassiveTransparent(500)
  565.            ELSE
  566.            IF Range(700) THEN
  567.               PassiveTransparent(700)
  568.            ELSE
  569.            IF Range(900) THEN
  570.               PassiveTransparent(900)
  571.            ELSE
  572.            IF Range(1100) THEN
  573.               PassiveTransparent(1100)
  574.            ELSE
  575.            BEGIN
  576.                 FOR J:=0 TO 63 DO
  577.                     SetColor(64+I,0,0,0);
  578.            END;
  579.            IF I=1 THEN
  580.               I:=63
  581.            ELSE Dec(I);
  582.            IF Range(100) THEN
  583.               ActiveTransparent(100)
  584.            ELSE
  585.            IF Range(300) THEN
  586.               ActiveTransparent(300)
  587.            ELSE
  588.            IF Range(500) THEN
  589.               ActiveTransparent(500)
  590.            ELSE
  591.            IF Range(700) THEN
  592.               ActiveTransparent(700)
  593.            ELSE
  594.            IF Range(900) THEN
  595.               ActiveTransparent(900)
  596.            ELSE
  597.            IF Range(1100) THEN
  598.               ActiveTransparent(1100)
  599.            ELSE SetColor(64+I,Gray,Gray,Gray);
  600.            Inc(Phase);
  601.            IF NOT Cancel AND KeyPressed THEN
  602.            BEGIN
  603.                 Cancel:=TRUE;
  604.                 Phase:=1330;
  605.            END;
  606.      UNTIL (Phase=1400) OR KeyPressed;
  607.      IF KeyPressed THEN
  608.         WaitKey;
  609. { Part II - Rotating Logo + Overlaying Copper Bars }
  610.      SetColor(0,63,63,63);
  611.      SetWriteMap(15);
  612.      ASM
  613.         mov ax,0a000h
  614.         mov es,ax
  615.         xor di,di
  616.         mov cx,2800
  617.         db 66h
  618.         xor ax,ax
  619.         cld
  620.         db 66h
  621.         rep stosw
  622.         mov di,20800
  623.         mov cx,2800
  624.         db 66h
  625.         rep stosw
  626.      END;
  627.      FOR I:=140 TO 259 DO
  628.      BEGIN
  629.           DrawLineH4(0,69,I,0);
  630.           DrawLineH4(250,319,I,0);
  631.      END;
  632.      FOR I:=0 TO 63 DO
  633.      BEGIN
  634. {
  635.           Split(I);
  636. }
  637.           VerticalRetrace;
  638.           SetColor(0,63-I,63-I,63-I);
  639.      END;
  640. {
  641.      SetStart(8000);
  642.      SetHorizOfs(0);
  643. }
  644.      FOR I:=0 TO 127 DO
  645.          SpiralTab[I]:=Round(255*Sin(I/64*Pi));
  646.      FOR I:=0 TO 255 DO
  647.          BarStartTab[I]:=127+Round(127*Sin(I/128*Pi));
  648.      FOR I:=0 TO 63 DO
  649.      BEGIN
  650.           BarTab[400+I]:=I;
  651.           BarTab[527-I]:=I;
  652.      END;
  653.      FOR I:=0 TO 399 DO
  654.          BarTab[I]:=0;
  655.      FOR I:=528 TO 799 DO
  656.          BarTab[I]:=0;
  657.      Phase:=0;
  658.      Radius:=0;
  659.      REPEAT
  660.            CLI;
  661.            IF Phase<1312 THEN
  662.            BEGIN
  663.                 Start:=128*320+(SpiralTab[(Phase+32) AND 127]*Radius) DIV 256;
  664.                 OfsLines:=128+(SpiralTab[Phase AND 127]*Radius*2) DIV 256;
  665.                 SetHorizOfs(Start AND 3);
  666.                 SetStart(Start SHR 2);
  667.            END
  668.            ELSE
  669.            IF Phase=1312 THEN
  670.            BEGIN
  671.                 OfsLines:=0;
  672.                 SetStart(0);
  673.                 SetHorizOfs(0);
  674.                 Split(124);
  675.            END;
  676.            IF Phase<61+9 THEN
  677.               StartR:=255+61+9-Phase
  678.            ELSE
  679.            IF Phase<957 THEN
  680.               StartR:=BarStartTab[Phase AND 255]
  681.            ELSE
  682.            IF Phase>1297 THEN
  683.               StartR:=1297-Phase
  684.            ELSE StartR:=0;
  685.            IF Phase<103 THEN
  686.               StartG:=383
  687.            ELSE
  688.            IF Phase<231+9 THEN
  689.               StartG:=255+231+9-Phase
  690.            ELSE
  691.            IF Phase<1127 THEN
  692.               StartG:=BarStartTab[(Phase+86) AND 255]
  693.            ELSE
  694.            IF Phase>1297 THEN
  695.               StartG:=1297-Phase
  696.            ELSE StartG:=0;
  697.            IF Phase<273 THEN
  698.               StartB:=383
  699.            ELSE
  700.            IF Phase<401+9 THEN
  701.               StartB:=255+401+9-Phase
  702.            ELSE
  703.            IF Phase<1042 THEN
  704.               StartB:=BarStartTab[(Phase+172) AND 255]
  705.            ELSE
  706.            IF Phase>1297 THEN
  707.               StartB:=1297-Phase
  708.            ELSE StartB:=0;
  709.            IF Phase>1297 THEN
  710.            BEGIN
  711.                 StartR:=0;
  712.                 StartG:=0;
  713.                 StartB:=0;
  714.            END;
  715. {
  716.            IF Phase>1367 THEN
  717.            BEGIN
  718.                 C:=0;
  719.                 IncC:=16128 DIV (64-(Phase-1367));
  720.                 FOR I:=0 TO 127 DO
  721.                 BEGIN
  722.                      BarTab[400+I]:=C SHR 8;
  723.                      Inc(C,IncC);
  724.                      IF (C<0) OR (C>16383) THEN
  725.                      BEGIN
  726.                           Dec(C,IncC);
  727.                           IncC:=-IncC;
  728.                      END;
  729.                 END;
  730.            END;
  731. }
  732.            SetColor(0,0,0,0);
  733.            SetOffset(0);
  734.            VerticalRetrace;
  735.            FOR I:=0 TO 7 DO
  736.            BEGIN
  737.                 IF I=OfsLines THEN
  738.                    SetOffset(40);
  739.                 Wait4Line;
  740.            END;
  741.            FOR I:=0 TO 383 DO
  742.            BEGIN
  743.                 IF I+8=OfsLines THEN
  744.                    SetOffset(40);
  745.                 SetColor(0,BarTab[(144+StartR) AND 511],BarTab[(144+StartG) AND 511],BarTab[(144+StartB) AND 511]);
  746.                 Wait4Line;
  747.                 Inc(StartR);
  748.                 Inc(StartG);
  749.                 Inc(StartB);
  750.            END;
  751.            SetColor(0,0,0,0);
  752.            FOR I:=0 TO 7 DO
  753.            BEGIN
  754.                 IF I=OfsLines THEN
  755.                    SetOffset(40);
  756.                 Wait4Line;
  757.            END;
  758.            IF (Phase<256) AND (Phase AND 3=0) THEN
  759.               Inc(Radius);
  760.            Inc(Phase);
  761.            STI;
  762.      UNTIL (Phase=1425) OR KeyPressed;
  763.      IF KeyPressed THEN
  764.         WaitKey;
  765.  
  766. { Phase III - Bouncing Scroller }
  767.  
  768.      ASM
  769.         mov dx,03c8h
  770.         mov al,0
  771.         out dx,al
  772.         out dx,al
  773.         out dx,al
  774.         mov si,offset standardpal
  775.         mov cx,768
  776.         inc dx
  777.         cld
  778.         rep outsb
  779.      END;
  780.      SetColor(128,0,0,63);
  781.      Port[$3C0]:=$10;
  782.      Port[$3C0]:=Port[$3C1] OR $20;
  783.      SetLineRepeat(0);
  784.      Split(200);
  785.      ScrollText1:='A A A A AAAA';
  786.      Phase:=0;
  787.      SetWriteMap(15);
  788.      REPEAT
  789.            CLI;
  790.            SetStart($8000+Phase SHR 2);
  791.            SetHorizOfs(Phase AND 3);
  792.            SetWriteMap(1 SHL (Phase AND 3));
  793.            FOR J:=0 TO 4 DO
  794.            BEGIN
  795.                 FOR I:=0 TO 11 DO
  796.                     Mem[$A800:(1+J*13+I)*80+Phase SHR 2+79]:=FontCh[2,Ord(ScrollText1[1+(Phase SHR 5) MOD
  797.                         Length(ScrollText1)])]^[4+(J*12+I) SHL 5+Phase AND 31];
  798.                 Mem[$A800:(J*13)*80+Phase SHR 2+79]:=0;
  799.            END;
  800.            SetOffset(0);
  801.            RasterLine:=0;
  802.            SetColor(0,0,0,0);
  803.            VerticalRetrace;
  804.            IF Phase AND 127<64 THEN
  805.               Count:=81-StartGap[Phase AND 127,5]
  806.            ELSE Count:=81+StartGap[Phase AND 63,3];
  807.            FOR I:=0 TO Count-1 DO
  808.            BEGIN
  809.                 Wait4Line;
  810.                 Inc(RasterLine);
  811.            END;
  812.            FOR I:=1 TO 5 DO
  813.                DrawFontBar(Phase AND 127,I);
  814.            FOR I:=RasterLine TO 199 DO
  815.                Wait4Line;
  816.            SetOffset(120);
  817.            StartR:=337;
  818.            FOR I:=0 TO 189 DO
  819.            BEGIN
  820.                 IF I=14 THEN
  821.                    SetOffset(80);
  822.                 IF I=70 THEN
  823.                    SetOffset(40);
  824.                 SetColor(0,BarTab[StartR],BarTab[StartR],BarTab[StartR]);
  825.                 Wait4Line;
  826.                 Inc(StartR);
  827.            END;
  828.            Inc(Phase);
  829.            STI;
  830.      UNTIL KeyPressed;
  831.      SetWriteMap(15);
  832.      ASM
  833.         mov ax,0a800h
  834.         mov es,ax
  835.         xor di,di
  836.         mov cx,8192
  837.         db 66h
  838.         xor ax,ax
  839.         cld
  840.         db 66h
  841.         rep stosw
  842.      END;
  843.      IF KeyPressed THEN
  844.         WaitKey;
  845.  
  846. { Part IV - Vertical bars as well as horizontal ones }
  847.  
  848.      Split(511);
  849.      SetHorizOfs(0);
  850.      LoadPalette('STANDARD');
  851.      FOR I:=0 TO 127 DO
  852.          SinVertTab[I]:=Round(144*Sin(I*Pi/64));
  853.      Phase:=0;
  854.      Start:=21000;
  855.      SetStart(Start);
  856.      REPEAT
  857.            CLI;
  858.            ASM
  859.               mov di,offset barline
  860.               mov ax,ds
  861.               mov es,ax
  862.               mov cx,160
  863.               xor ax,ax
  864.               rep stosw
  865.            END;
  866.            FOR J:=1 TO 8 DO
  867.                IF (Phase>23+(8-J)*72) AND (Phase<23+1512-256+J*72) THEN
  868.                BEGIN
  869.                     K:=144+SinVertTab[(Phase+J SHL 3) AND 127];
  870.                     ASM
  871.                        mov ax,ds
  872.                        mov es,ax
  873.                        mov di,offset barline
  874.                        add di,k
  875.                        mov cx,8
  876.                        add cx,j
  877.                        mov ax,j
  878.                        shl ax,4
  879.                        add al,15
  880. @1:                    stosb
  881.                        dec ax
  882.                        loop @1
  883.                        mov cx,8
  884.                        add cx,j
  885.                        inc ax
  886. @2:                    stosb
  887.                        inc ax
  888.                        loop @2
  889.                     END;
  890.                END;
  891.            IF Phase<512+32 THEN
  892.               K:=0
  893.            ELSE
  894.            FOR I:=0 TO 3 DO
  895.            BEGIN
  896.                 SetWriteMap(1 SHL I);
  897.                 ASM
  898.                    mov si,offset barline
  899.                    mov ax,0a000h
  900.                    mov es,ax
  901.                    mov di,start
  902.                    add si,i
  903.                    mov cx,40
  904.                    cld
  905. @1:                mov al,[si]
  906.                    mov ah,[si+4]
  907.                    add si,8
  908.                    stosw
  909.                    loop @1
  910.                 END;
  911.            END;
  912.            IF (Phase>=1120) AND (Phase<1120+112) THEN
  913.               K:=Phase-832
  914.            ELSE
  915.            IF (Phase>=1120+112) AND (Phase<1120+144) THEN
  916.               K:=400
  917.            ELSE
  918.            IF (Phase>=1120+144) AND (Phase<1120+256) THEN
  919.               K:=1664-Phase
  920.            ELSE
  921.            IF Phase=1120+256 THEN
  922.            BEGIN
  923.                 SetWriteMap(15);
  924.                 FillChar(Ptr($A000,21000)^,81,0);
  925.                 Start:=11040-16*80;
  926.                 SetStart(Start);
  927.            END;
  928.            SetOffset(0);
  929.            WaitScreen;
  930.            ASM
  931.               mov si,offset barline
  932.            END;
  933.            FOR I:=0 TO 319 DO
  934.            BEGIN
  935.                 IF I=K THEN
  936.                    SetOffset(40);
  937.                 ASM
  938. @1:                mov dx,$3da
  939.                    in al,dx
  940.                    test al,1
  941.                    jnz @1
  942.  
  943.                    lodsb
  944.                    cmp al,0
  945.                    jnz @1a
  946.                    mov dx,$3c8
  947.                    out dx,al
  948.                    inc dx
  949.                    out dx,al
  950.                    out dx,al
  951.                    out dx,al
  952.                    jmp @1b
  953. @1a:               mov dx,$3c7
  954.                    out dx,al
  955.                    inc dx
  956.                    inc dx
  957.                    in al,dx
  958.                    mov bh,al
  959.                    in al,dx
  960.                    mov bl,al
  961.                    in al,dx
  962.                    mov ah,al
  963.                    mov al,0
  964.                    dec dx
  965.                    out dx,al
  966. @1b:
  967.                    mov dx,$3da
  968. @4:                in al,dx
  969.                    test al,1
  970.                    jz @4
  971.                    mov dx,$3c9
  972.                    mov al,bh
  973.                    out dx,al
  974.                    mov al,bl
  975.                    out dx,al
  976.                    mov al,ah
  977.                    out dx,al
  978.                 END;
  979.            END;
  980.            SetColor(0,0,0,0);
  981.            FOR I:=0 TO 79 DO
  982.            BEGIN
  983.                 IF K-320=I THEN
  984.                    SetOffset(40);
  985.                 Wait4Line;
  986.            END;
  987.            WaitRetrace;
  988.            Inc(Phase);
  989.            STI;
  990.      UNTIL (Phase=2048) OR KeyPressed;
  991.      SetWriteMap(15);
  992.      ASM
  993.         mov ax,0a000h
  994.         mov es,ax
  995.         xor di,di
  996.         mov cx,8192
  997.         db 66h
  998.         xor ax,ax
  999.         cld
  1000.         db 66h
  1001.         rep stosw
  1002.      END;
  1003.      IF KeyPressed THEN
  1004.         WaitKey;
  1005.  
  1006. { Phase V - Vertical Overlaying Sine Bars }
  1007.  
  1008.      SetStart(0);
  1009.      SetOffset(0);
  1010.      FOR I:=0 TO 1023 DO
  1011.          Line[I]:=152+Round(70*Sin(I*Pi/256)+Round(40*Sin(I*Pi/64)));
  1012.      FOR I:=0 TO 1023 DO
  1013.          Line2[I]:=Round(50*Sin(I*Pi/64));
  1014.      I:=0;
  1015.      FOR I:=1 TO 6 DO
  1016.          SetColor(I,I SHL 3+15,I SHL 3+15,0);
  1017.      Phase:=0;
  1018.      K:=0;
  1019.      Rechain;
  1020.      REPEAT
  1021.            CLI;
  1022.            IF Phase<400 THEN
  1023.               Inc(K)
  1024.            ELSE
  1025.            IF Phase>1024-400 THEN
  1026.               Dec(K);
  1027.            IF I>=1023 THEN
  1028.               I:=0
  1029.            ELSE Inc(I,4);
  1030.            SetOffset(0);
  1031.            WaitScreen;
  1032.            ASM
  1033.               mov ax,0a000h
  1034.               mov es,ax
  1035.               xor di,di
  1036.               mov cx,80
  1037.               db 66h
  1038.               xor ax,ax
  1039.               cld
  1040.               db 66h
  1041.               rep stosw
  1042.               mov si,i
  1043.               mov bx,si
  1044.            END;
  1045.            ASM
  1046.               mov cx,k
  1047.               cld
  1048.               mov dx,03dah
  1049. @1:           in al,dx
  1050.               test al,1
  1051.               jz @1
  1052.               mov di,[offset line+si]
  1053.               add di,[offset line2+bx]
  1054.               and di,7fffh
  1055.               add si,2
  1056.               and si,1023
  1057.               add bx,4
  1058.               and bx,1023
  1059. @1b:          mov ax,$0201
  1060.               stosw
  1061.               mov ax,$0403
  1062.               stosw
  1063.               mov ax,$0605
  1064.               stosw
  1065.               mov ax,$0506
  1066.               stosw
  1067. @2:           in al,dx
  1068.               test al,1
  1069.               jnz @2
  1070.               mov ax,$0304
  1071.               stosw
  1072.               mov ax,$0102
  1073.               stosw
  1074.               loop @1
  1075.            END;
  1076.            SetOffset(40);
  1077.            IF K<399 THEN
  1078.            BEGIN
  1079.                 Wait4Line;
  1080.                 SetOffset(0);
  1081.            END;
  1082.            WaitRetrace;
  1083.            Inc(Phase);
  1084.            STI;
  1085.      UNTIL (Phase=1024) OR KeyPressed;
  1086.      IF KeyPressed THEN
  1087.         WaitKey;
  1088.  
  1089. { Part VI - Plasma }
  1090.  
  1091.      FOR I:=0 TO 255 DO
  1092.          SinTable[I]:=32+Round(31*Sin(I/128*Pi));
  1093.      FOR I:=0 TO 1023 DO
  1094.          OfsRel[I]:=Round(8*Sin(I/20));
  1095.      LastOfs:=OfsRel[0];
  1096.      OfsTable[0]:=80;
  1097.      FOR I:=1 TO 1023 DO
  1098.      BEGIN
  1099.           IF OfsRel[I]<>LastOfs THEN
  1100.              OfsTable[I]:=80+LastOfs-OfsRel[I]
  1101.           ELSE OfsTable[I]:=80;
  1102.           LastOfs:=OfsRel[I];
  1103.      END;
  1104.      SwitchOff;
  1105.      Unchain;
  1106.      SetLineRepeat(0);
  1107.      FOR I:=0 TO 63 DO
  1108.      BEGIN
  1109.           SetColor(128+I,I,0,0);
  1110.           SetColor(255-I,I,0,0);
  1111.      END;
  1112.      SetOffset(80);
  1113.      FOR I:=0 TO 639 DO
  1114.      BEGIN
  1115.           Adr:=I SHR 2;
  1116.           SetWriteMap(1 SHL (I AND 3));
  1117.           FOR J:=0 TO 399 DO
  1118.           BEGIN
  1119.                ASM
  1120.                   mov ah,0
  1121.                   mov bx,i
  1122.                   shr bx,1
  1123.                   mov bh,0
  1124.                   mov al,[offset sintable+bx]
  1125.                   mov bx,j
  1126.                   shl bx,1
  1127.                   mov bh,0
  1128.                   add al,[offset sintable+bx]
  1129.                   shr bx,2
  1130.                   mov bh,0
  1131.                   add al,[offset sintable+bx]
  1132.                   mov bx,i
  1133.                   add bx,j
  1134.                   shr bx,1
  1135.                   mov bh,0
  1136.                   add al,[offset sintable+bx]
  1137.  
  1138.                   mov bx,i
  1139.                   sub bx,j
  1140.                   mov bh,0
  1141.                   add al,[offset sintable+bx]
  1142.                   adc ah,0
  1143. {
  1144.                   mov bx,639
  1145.                   sub bx,i
  1146.                   push ax
  1147.                   mov ax,j
  1148.                   mul bx
  1149.                   shr ax,7
  1150.                   mov bl,al
  1151.                   pop ax
  1152.                   add al,[offset sintable+bx]
  1153.                   adc ah,0
  1154.                   push ax
  1155.                   mov bx,j
  1156.                   inc bx
  1157.                   mov ax,i
  1158.                   div bx
  1159.                   shr ax,5
  1160.                   mov bl,al
  1161.                   pop ax
  1162.                   add al,[offset sintable+bx]
  1163.                   adc ah,0
  1164. }
  1165.                   mov bx,j
  1166.                   shl bx,1
  1167.                   mov bh,0
  1168.                   add al,[offset sintable+bx]
  1169.                   adc ah,0
  1170.                   mov color,al
  1171.                   and al,127
  1172.                   add al,128
  1173.                   mov bx,0a000h
  1174.                   mov es,bx
  1175.                   mov di,adr
  1176.                   stosb
  1177.                END;
  1178. {
  1179.                Color:=(SinTable[Byte(I SHR 1)]+
  1180.                        SinTable[Byte(J SHR 1)]+
  1181.                        SinTable[Byte((I+J) SHR 1)]+
  1182.                        SinTable[Byte(J SHL 1)]+
  1183.                        SinTable[Byte((I-J) SHR 1)]+
  1184.                        SinTable[Byte(((639-I)*(J)) SHR 7)]+
  1185.                        SinTable[Byte((I DIV (J+1)) SHR 5)]+
  1186.                        SinTable[Byte(J SHL 1)]) SHR 1;
  1187.                Mem[$A000:Adr]:=128+Color AND 127;
  1188. }
  1189.                Inc(Adr,160);
  1190.           END;
  1191.      END;
  1192.      SwitchOn;
  1193.      J:=0;
  1194.      Start:=0;
  1195.      Dir:=1;
  1196.      SetStart(40);
  1197.      REPEAT
  1198.            CLI;
  1199.            DrawPlasma;
  1200.            Inc(Start,Dir);
  1201.            IF (Start=0) OR (Start=1023) THEN
  1202.               Dir:=-Dir;
  1203.            Inc(J,2);
  1204.            IF J>127 THEN
  1205.               J:=0;
  1206.            STI;
  1207.      UNTIL (Phase=1024) OR KeyPressed;
  1208.      IF KeyPressed THEN
  1209.         WaitKey;
  1210.      SetModeNr(3);
  1211. END.